<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="div1">
        我是div1
    </div>
    <div>111</div>
    <div>222</div>
    <div class="movie">movie</div>
    <div class="movie">movie</div>
    <div class="movie">movie</div>
    <div class="movie">movie</div>
    <div class="movie">movie</div>
    <button class="btn1">点我试试</button>
    <script>
        // 可以拿着id直接当做元素来使用
        var div = document.getElementById('div1');
        console.log(div);
        var divs = document.getElementsByTagName('div');
        // 返回值是符合条件的元素集合 是一个类数组
        console.log(divs[2]);
        var movieDiv = document.getElementsByClassName('movie');
        console.log(movieDiv);
        // 根据选择器 选择第一个符合条件的元素
        var divFirst = document.querySelector('#div1');
        console.log(divFirst);
        // 根据选择器 选择所有符合条件的元素
        var divAll = document.querySelectorAll('div');
        console.log(divAll);
        var btn = document.querySelector('.btn1');
        btn.onclick = function() {
            console.log('试试就逝世');
        }
    </script>
</body>
</html>